package com.example.sneakerappforme1105.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.example.sneakerappforme1105.orderFragment.AllOrderFragment;
import com.example.sneakerappforme1105.orderFragment.DeliverFragment;
import com.example.sneakerappforme1105.orderFragment.PaidFragment;
import com.example.sneakerappforme1105.orderFragment.PayFragment;

import java.util.List;

public class OrderPagerAdapter extends FragmentStateAdapter {
    private List<String> mTitleList;

    public OrderPagerAdapter(FragmentActivity fa, List<String>mTitleList){
        super(fa);
        this.mTitleList = mTitleList;
    }


    @Override
    public Fragment createFragment(int position) {
        if(position == 0){
            //展示服装，第一页
            return new AllOrderFragment();
        }else if(position == 1){
            return new PayFragment();  // 嵌套Fragment
        }else if(position == 2){
            return new PaidFragment();
        }else{
            return new DeliverFragment();
        }
    }

    @Override
    public int getItemCount() {
        return mTitleList.size();
    }
}
